package com.ruoyi.park.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.park.mapper.BuiRoomFacilityMapper;
import com.ruoyi.omp.api.domain.BuiRoomFacility;
import com.ruoyi.park.service.IBuiRoomFacilityService;

/**
 * 配套设施Service业务层处理
 *
 * @author cjie
 * @date 2021-08-31
 */
@Service
public class BuiRoomFacilityServiceImpl implements IBuiRoomFacilityService {
    @Autowired
    private BuiRoomFacilityMapper buiRoomFacilityMapper;

    /**
     * 查询配套设施
     *
     * @param id 配套设施ID
     * @return 配套设施
     */
    @Override
    public BuiRoomFacility selectBuiRoomFacilityById(String id) {
        return buiRoomFacilityMapper.selectBuiRoomFacilityById(id);
    }

    /**
     * 查询配套设施列表
     *
     * @param buiRoomFacility 配套设施
     * @return 配套设施
     */
    @Override
    public List<BuiRoomFacility> selectBuiRoomFacilityList(BuiRoomFacility buiRoomFacility) {
        return buiRoomFacilityMapper.selectBuiRoomFacilityList(buiRoomFacility);
    }

    /**
     * 新增配套设施
     *
     * @param buiRoomFacility 配套设施
     * @return 结果
     */
    @Override
    public int insertBuiRoomFacility(BuiRoomFacility buiRoomFacility) {
        buiRoomFacility.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        buiRoomFacility.setCreateTime(DateUtils.getNowDate());
        buiRoomFacility.setCreateBy(SecurityUtils.getUsername());
        return buiRoomFacilityMapper.insertBuiRoomFacility(buiRoomFacility);
    }

    /**
     * 修改配套设施
     *
     * @param buiRoomFacility 配套设施
     * @return 结果
     */
    @Override
    public int updateBuiRoomFacility(BuiRoomFacility buiRoomFacility) {
        buiRoomFacility.setUpdateTime(DateUtils.getNowDate());
        buiRoomFacility.setUpdateBy(SecurityUtils.getUsername());
        return buiRoomFacilityMapper.updateBuiRoomFacility(buiRoomFacility);
    }

    /**
     * 批量删除配套设施
     *
     * @param ids 需要删除的配套设施ID
     * @return 结果
     */
    @Override
    public int deleteBuiRoomFacilityByIds(String[] ids) {
        return buiRoomFacilityMapper.deleteBuiRoomFacilityByIds(ids);
    }

    /**
     * 删除配套设施信息
     *
     * @param id 配套设施ID
     * @return 结果
     */
    @Override
    public int deleteBuiRoomFacilityById(String id) {
        return buiRoomFacilityMapper.deleteBuiRoomFacilityById(id);
    }
}
